import { getCurrentUser } from '@/api/login';
import { getCookie } from '@/utils/cookies';
import { getBaseUrl, getQueryVariable } from '@/utils/http';
import { defineComponent, onMounted, ref } from 'vue';

const Home = defineComponent({
  props: {},
  setup() {
    const classA = ref('');
    onMounted(async () => {
      const token = getQueryVariable('token');
      const param = getQueryVariable('param');
      if (token) {
        await getCurrentUser(token);
      }
      if (!param) {
        window.location.replace(getBaseUrl('') + window.location.pathname);
      } else {
        window.location.replace(param);
      }
    });
    return () => <div class={classA}></div>;
  }
});

Home.displayName = 'Home';

export default Home;
